package com.cn.intelligence.service.impl;

import com.cn.intelligence.mapper.TbVideoMapper;
import com.cn.intelligence.pojo.TbVideo;
import com.cn.intelligence.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {
    @Value("${VIDEO_PAH}")
    private String videoPath;
    @Value("${VIDEOS_SERVER}")
    private String videoServer;

    @Autowired
    private TbVideoMapper mapper;

    public boolean addVideo(TbVideo video) {
        return video != null && mapper.insertVideo(video) == 1;
    }

    public boolean deleteVideo(int id) {
        return mapper.deleteVideo(id) == 1;
    }

    public TbVideo selectById(int id) {
        return mapper.selectById(id);
    }

    public PageInfo<TbVideo> selectAll(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<TbVideo> videoList = mapper.selectAll();
        // 获取总数
        return new PageInfo<>(videoList);
    }

    public String getVideoPath() {
        return videoPath;
    }

    public String getVideoServer() {
        return videoServer;
    }
}
